package com.atguigu05.exer.exer3;

/**
 * @author NoobMaster69  * @date 2024/6/2 0002 星期日 20:58
 */
public class Person {
    private String name;
    private Integer lifeValue;

    public Person() {
    }

    public Person(String name, Integer lifeValue) throws NoLifeValueException{
        setName(name);
        setLifeValue(lifeValue);

    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getLifeValue() {
        return lifeValue;
    }

    public void setLifeValue(Integer lifeValue){
        if(lifeValue < 0){
            throw new NoLifeValueException("血量不能为负数:" + lifeValue);
        }
            this.lifeValue = lifeValue;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", lifeValue=" + lifeValue +
                '}';
    }
}
